<?php
class PropertyTest
{

  private $data = array();  /**  Location for overloaded data.  */

  public $declared = 1;  /**  Overloading not used on declared properties.  */

  private $hidden = 2;  /**  Overloading only used on this when accessed outside the class.  */


  public function __set($name, $value)
  {
    echo '<br>I am in __set()<br>';

    echo "Setting '$name' to '$value'<br>";
    $this->data[$name] = $value;
  }

  public function __get($name)
  {
    echo '<br>I am in __get()<br>';

    echo "Getting '$name'<br>";
    if (array_key_exists($name, $this->data)) {
        return $this->data[$name];
    }
  }

  /**  As of PHP 5.1.0  */
  public function __isset($name)
  {
    echo '<br>I am in __isset()<br>';

    echo "Is '$name' set?<br>";
    return isset($this->data[$name]);
  }

  /**  As of PHP 5.1.0  */
  public function __unset($name)
  {
    echo '<br>I am in __unset()<br>';

    echo "Unsetting '$name'<br>";
    unset($this->data[$name]);
  }

  /**  Not a magic method, just here for example.  */
  public function getHidden()
  {
    echo '<br>I am in getHidden()<br>';

    return $this->hidden;
  }
}


echo "<pre><br>";

$obj = new PropertyTest;

$obj->a = 1;



$obj->a . " This is Value of A<br><br>";
var_dump(isset($obj->a));

unset($obj->a);
exit;
var_dump(isset($obj->a));
echo "<br>";

echo $obj->declared . "<br><br>";

echo $obj->getHidden() . "<br>";

echo $obj->hidden . "<br>";
